#ifndef _lm_util_h_
#define _lm_util_h_

#include "stdint.h"

#define SET_DATA_VALID(x)        (x) = 1
#define SET_DATA_INVALID(x)      (x) = 0
#define DATA_IS_VALID(x)       ((x) == 1)
#define DATA_IS_INVALID(x)     ((x) == 0)

#define combin16(h,l) (((uint16_t)(h))<<8|l)
#define combin32(hh,h,l,ll) (((uint32_t)(hh))<<24|((uint32_t)(h))<<16|((uint32_t)(l))<<8|ll)

#define STR_VAL(str)  #str

extern char *hex_2_string(const unsigned char hex[], int length);
extern bool StringToHex(char *str, unsigned char *strhex);
//extern uint8_t lm_util_get_xor(uint8_t *ptr, uint8_t len);
//extern bool is_all_ff(uint8_t* buf, uint8_t len);

extern uint16 gen_crc16(const uint8 *data, uint16 size);

extern uint16_t lm_crc_x25(uint8_t *puchMsg, uint16_t usDataLen);

#endif
